/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.agreement.entity.yearcarsalepurchaseagreement;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.guarantor.Guarantor;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.sys.entity.Company;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 年度汽车买卖协议Entity
 * @author Kilo
 * @version 2021-03-04
 */
@Table(name="t_year_car_sale_purchase_agreement", alias="a", columns={
		@Column(name="year_car_sale_purchase_agreement_id", attrName="yearCarSalePurchaseAgreementId", label="年度汽车买卖协议ID", isPK=true),
		@Column(name="year_car_sale_purchase_agreement_code", attrName="yearCarSalePurchaseAgreementCode", label="协议编号"),
		@Column(name="sign_date", attrName="signDate", label="签订日期"),
		@Column(name="sign_location", attrName="signLocation", label="签订地点"),
		@Column(name="status1", attrName="status1", label="状态"),
		@Column(includeEntity=DataEntity.class),
		@Column(name="start_date", attrName="startDate", label="开始日期"),
		@Column(name="end_date", attrName="endDate", label="结束日期"),
		@Column(name="investor_id", attrName="investorId", label="甲方", comment="甲方(卖方)"),
		@Column(name="investor_address", attrName="investorAddress", label="地址"),
		@Column(name="investor_phone", attrName="investorPhone", label="电话"),
		@Column(name="investor_fax", attrName="investorFax", label="传真"),
		@Column(name="company_id", attrName="company.companyCode", label="乙方", comment="乙方(买方)"),
		@Column(name="company_address", attrName="companyAddress", label="地址"),
		@Column(name="company_phone", attrName="companyPhone", label="电话"),
		@Column(name="company_fax", attrName="companyFax", label="传真"),
		@Column(name="guarantor_id", attrName="guarantorId", label="丙方", comment="丙方(担保方)"),
		@Column(name="guarantor_id_number", attrName="guarantorIdNumber", label="身份证号"),
		@Column(name="guarantor_address", attrName="guarantorAddress", label="地址"),
		@Column(name="guarantor_phone", attrName="guarantorPhone", label="电话"),
	}, joinTable={
		@JoinTable(type=Type.LEFT_JOIN, entity= Company.class, attrName="company", alias="u11",
				on="u11.company_code = a.company_id", columns={
				@Column(name="company_code", label="公司编码", isPK=true),
				@Column(name="company_name", label="公司名称", isQuery=false),
		}),
		@JoinTable(type=Type.LEFT_JOIN, entity= Supplier.class, attrName="supplier", alias="u12",
				on="u12.supplier_id = a.investor_id", columns={
				@Column(name="supplier_id", label="供应商编码", isPK=true),
				@Column(name="supplier_name", label="供应商名称", isQuery=false),
		}),
		@JoinTable(type=Type.LEFT_JOIN, entity= Guarantor.class, attrName="guarantor", alias="u13",
				on="u13.guarantor_id = a.guarantor_id", columns={
				@Column(name="guarantor_id", label="担保方编码", isPK=true),
				@Column(name="guarantor_name", label="担保方名称", isQuery=false),
		}),
},orderBy="a.update_date DESC"
)
public class YearCarSalePurchaseAgreement extends DataEntity<YearCarSalePurchaseAgreement> {
	
	private static final long serialVersionUID = 1L;
	private String yearCarSalePurchaseAgreementId;		// 年度汽车买卖协议ID
	private String yearCarSalePurchaseAgreementCode;		// 协议编号
	private Date signDate;		// 签订日期
	private String signLocation;		// 签订地点
	private String status1;		// 状态
	private Date startDate;		// 开始日期
	private Date endDate;		// 结束日期
	private String investorId;
	private String investorAddress;		// 地址
	private String investorPhone;		// 电话
	private String investorFax;		// 传真
	private String companyAddress;		// 地址
	private String companyPhone;		// 电话
	private String companyFax;		// 传真
	private String guarantorId;		// 丙方(担保方)
	private String guarantorIdNumber;		// 身份证号
	private String guarantorAddress;		// 地址
	private String guarantorPhone;		// 电话
	private Company company;
	private Supplier supplier;
	private Guarantor guarantor;

	public String getInvestorId() {
		return investorId;
	}

	public void setInvestorId(String investorId) {
		this.investorId = investorId;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public Guarantor getGuarantor() {
		return guarantor;
	}

	public void setGuarantor(Guarantor guarantor) {
		this.guarantor = guarantor;
	}

	public YearCarSalePurchaseAgreement() {
		this(null);
	}

	public YearCarSalePurchaseAgreement(String id){
		super(id);
	}
	
	public String getYearCarSalePurchaseAgreementId() {
		return yearCarSalePurchaseAgreementId;
	}

	public void setYearCarSalePurchaseAgreementId(String yearCarSalePurchaseAgreementId) {
		this.yearCarSalePurchaseAgreementId = yearCarSalePurchaseAgreementId;
	}
	
	@Length(min=0, max=100, message="协议编号长度不能超过 100 个字符")
	public String getYearCarSalePurchaseAgreementCode() {
		return yearCarSalePurchaseAgreementCode;
	}

	public void setYearCarSalePurchaseAgreementCode(String yearCarSalePurchaseAgreementCode) {
		this.yearCarSalePurchaseAgreementCode = yearCarSalePurchaseAgreementCode;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="签订日期不能为空")
	public Date getSignDate() {
		return signDate;
	}

	public void setSignDate(Date signDate) {
		this.signDate = signDate;
	}
	
	@NotBlank(message="签订地点不能为空")
	@Length(min=0, max=50, message="签订地点长度不能超过 50 个字符")
	public String getSignLocation() {
		return signLocation;
	}

	public void setSignLocation(String signLocation) {
		this.signLocation = signLocation;
	}
	
	@NotBlank(message="状态不能为空")
	@Length(min=0, max=1, message="状态长度不能超过 1 个字符")
	public String getStatus1() {
		return status1;
	}

	public void setStatus1(String status1) {
		this.status1 = status1;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="开始日期不能为空")
	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="结束日期不能为空")
	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	@NotBlank(message="地址不能为空")
	@Length(min=0, max=255, message="地址长度不能超过 255 个字符")
	public String getInvestorAddress() {
		return investorAddress;
	}

	public void setInvestorAddress(String investorAddress) {
		this.investorAddress = investorAddress;
	}
	
	@NotBlank(message="电话不能为空")
	@Length(min=0, max=100, message="电话长度不能超过 100 个字符")
	public String getInvestorPhone() {
		return investorPhone;
	}

	public void setInvestorPhone(String investorPhone) {
		this.investorPhone = investorPhone;
	}
	
	@NotBlank(message="传真不能为空")
	@Length(min=0, max=100, message="传真长度不能超过 100 个字符")
	public String getInvestorFax() {
		return investorFax;
	}

	public void setInvestorFax(String investorFax) {
		this.investorFax = investorFax;
	}
	
	@NotBlank(message="地址不能为空")
	@Length(min=0, max=255, message="地址长度不能超过 255 个字符")
	public String getCompanyAddress() {
		return companyAddress;
	}

	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}
	
	@NotBlank(message="电话不能为空")
	@Length(min=0, max=100, message="电话长度不能超过 100 个字符")
	public String getCompanyPhone() {
		return companyPhone;
	}

	public void setCompanyPhone(String companyPhone) {
		this.companyPhone = companyPhone;
	}
	
	@NotBlank(message="传真不能为空")
	@Length(min=0, max=100, message="传真长度不能超过 100 个字符")
	public String getCompanyFax() {
		return companyFax;
	}

	public void setCompanyFax(String companyFax) {
		this.companyFax = companyFax;
	}
	
	@NotBlank(message="丙方不能为空")
	@Length(min=0, max=64, message="丙方长度不能超过 64 个字符")
	public String getGuarantorId() {
		return guarantorId;
	}

	public void setGuarantorId(String guarantorId) {
		this.guarantorId = guarantorId;
	}
	
	@NotBlank(message="身份证号不能为空")
	@Length(min=0, max=100, message="身份证号长度不能超过 100 个字符")
	public String getGuarantorIdNumber() {
		return guarantorIdNumber;
	}

	public void setGuarantorIdNumber(String guarantorIdNumber) {
		this.guarantorIdNumber = guarantorIdNumber;
	}
	
	@NotBlank(message="地址不能为空")
	@Length(min=0, max=200, message="地址长度不能超过 200 个字符")
	public String getGuarantorAddress() {
		return guarantorAddress;
	}

	public void setGuarantorAddress(String guarantorAddress) {
		this.guarantorAddress = guarantorAddress;
	}
	
	@NotBlank(message="电话不能为空")
	@Length(min=0, max=100, message="电话长度不能超过 100 个字符")
	public String getGuarantorPhone() {
		return guarantorPhone;
	}

	public void setGuarantorPhone(String guarantorPhone) {
		this.guarantorPhone = guarantorPhone;
	}
	
	public Date getSignDate_gte() {
		return sqlMap.getWhere().getValue("sign_date", QueryType.GTE);
	}

	public void setSignDate_gte(Date signDate) {
		sqlMap.getWhere().and("sign_date", QueryType.GTE, signDate);
	}
	
	public Date getSignDate_lte() {
		return sqlMap.getWhere().getValue("sign_date", QueryType.LTE);
	}

	public void setSignDate_lte(Date signDate) {
		sqlMap.getWhere().and("sign_date", QueryType.LTE, signDate);
	}
	public void setStartDate_check(Date startDate){
		sqlMap.getWhere().andBracket("start_date", QueryType.LTE, startDate).and("end_date", QueryType.GTE,startDate );
	}
	public Date getStartDate_check(){
		return sqlMap.getWhere().getValue("start_date", QueryType.LTE);
	}
	public void setEndDate_check(Date endDate){
		sqlMap.getWhere().orBracket("start_date", QueryType.LTE, endDate).and("end_date", QueryType.GTE,endDate ).endBracket().endBracket();
	}
	public Date getEndDate_check(){
		return sqlMap.getWhere().getValue("end_date", QueryType.GTE);
	}

}